import BaseModel from "../../libs/lightMVC/core/base/BaseModel";
import Notification from "../Notification";

export enum ShowroomType {

    No = 0,           //无
    Match = 1,        //赛事馆
    Person = 2,       //个人馆
}

export enum ShowroonStyle{
   
    Industrial = 1,//工业风
    Postmodernism = 2, //后现代
    DreamCastle = 3 ,  //梦幻城堡   
}
export default class PlayerModel extends BaseModel {

    private _player: Player;

    private _showroom: ShowroomInfo;

    public _gameConfig : GameConfig;        //游戏中的设置，例如播放背景音乐等

    public _isBack : boolean = false;

    public init(): void {

        console.log("初始化用户数据模块");

        this._player = new Player("");

        this._showroom = new ShowroomInfo(0);

        this._gameConfig = new GameConfig();
    }

    /**
     * 当前用户拥有美术馆
     */
    public ownGallery(own: boolean) {

        this._player.ownGallery = own;

        this.sendNoti(Notification.OWN_GALLERY);
    }

    public getPlayer(): Player {

        return this._player;
    }

    public getShowroomInfo(): ShowroomInfo {

        return this._showroom;
    }

    /**
     * 当前打开的图片
     */
    public getOpenedImageDetail(){

        this.debugOpenedImageDetail();      //测试数据

        return this._player.openedImageDetail;
    }

    /**
     * 这里是测试信息
     */
    private debugOpenedImageDetail(){

        let t_image = new ImageData();

        t_image.id = 0;
        t_image.title = "梵高星空  星月夜";
        t_image.introduceContent = "在这幅画中，梵·高用夸张的手法，生动地描绘了充满运动和变化的星空。夜晚的天空高又远，大星、小星回旋于夜空，金黄的满月形成巨大的漩涡，星云的短线条纠结、盘旋，仿佛让人们看见时光的流逝。暗绿褐色的柏树像巨大的火焰，是星夜狂欢的响应者。天空下，安睡的村庄那么宁静、安详。淡蓝的色调，动感的线条，给人自由的时空感";
        t_image.url = "http://h5files.oss-cn-hangzhou.aliyuncs.com/artGallery/test/%E6%98%9F%E7%A9%BA.jpg";

        this._player.openedImageDetail = t_image;
    }

    /**
     * 切换音乐播放状态
     * @param isPlaying 音乐的播放状态
     */
    public musicStateChange(isPlaying: boolean): void {

        this._gameConfig.musicIsPlaying = isPlaying;

        if (isPlaying) {

            this.sendNoti(Notification.MUSIC_PLAYING);

        } else {

            this.sendNoti(Notification.MUSIC_PAUSE);
        }
    }

    public clear(): void {

    }
}

/**
 * 游戏中基础信息
 */
export class Player {

    public openid: string;      //微信openid

    public wechatid : string;    //微信wechatid

    public nickname :string;     //微信名称

    public header : string;       //微信头像

    public uid : string;          //可领取美术馆uid

    public ownGallery : boolean = false;       //是否拥有美术馆

    public likeworks : Array<Number>  = [];     //用户的点赞作品集

    public areaInfoList: Array<AreaInfo> = [];      //用户所拥有的的区域和信息

    public showcaseImageList: Array<ImageData> = [];      //存放单张图片信息的列表

    public curSelectedImageData: ImageData;     //当前点击的图像


    public _curShowcaseId: string = "";      //当前展示区的ID


    public openedImageDetail :ImageData;        //当前打开的图片

    

    get curShowcaseId() {

        return this._curShowcaseId;
    }
    set curShowcaseId(value) {

        this._curShowcaseId = value;
    }

    public constructor(openid: string) {

        this.openid = openid;

        //this.writeDebugData();
    }

    /**
     * 测试数据
     */
   /* private writeDebugData() {

        this.areaInfoList.push(new AreaInfo("全部"));
    }*/
}

/** 定义美术馆的基础信息 */
export class ShowroomInfo {

    public id: number ;

    public exh_id : number ;

    public name: string;        //美术馆的名字

    public showroomType: ShowroomType = ShowroomType.No;       //赛馆类型

    public showroomStyle : ShowroonStyle = ShowroonStyle.Postmodernism; // 展馆类型工业风

    public showroomindex: number;   //展示的圖片index

    public texturecurindex : number = 0;
    public constructor(id:number) {

        //这里是测试数据  189
        this.id = id;

       
    }
}

/**
 * 用户所拥有的的区域和信息
 */
export class AreaInfo {

    public name: string;        //区域名字
    public exh_id : number      //展区id
    public styleid : number     //风格id
    public constructor(name: string,id:number,styleid :number) {

        this.name = name;
        this.exh_id = id;
        this.styleid = styleid;
    }
}

/**
 * 单张图片的信息
 */
export class ImageData {

    public id: number;      //作品id

    public title: string;        //作品名字

    public tag: string;        //作品标签，所属区域

    public spriteFrameThumb: string;    //作品缩略图

    public spriteFrameContent : string ;//作品完整图地址

    public url: string;        //图片远程地址

    public introduceContent: string;      //作品简介

    public liked: string;        //当前用户是否点赞

    public likeCount: number = 0;      //当前作品的点赞数量

    public imageposition : number ; //作品摆放位置

    public imagestatus : string //作品显示状态
}






/**
 * 用户所拥有的的区域和信息
 */
export class GameConfig {

    public musicIsPlaying: boolean = true;        //背景音乐是否正在播放
}
